#@layout()

#define script()
<script>

    function doDel(id) {
        ajaxGet("/admin/job/categoryDoDel/" + id);
    }

</script>
#end

#define content()

<section class="content-header">
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-6">

                <div class="row mb-2">
                    <div class="col-sm-12">
                        <h1>
                            #if(type == "category") 招聘分类 #else if(type == "address") 招聘地址 #end
                            <small data-toggle="tooltip" title="" data-placement="right"
                                   data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                            <small> 首页 / 招聘 /   #if(type == "category") 分类管理 #else if(type == "address") 地址管理 #end</small>
                        </h1>
                    </div>
                </div>
            </div>
        </div>

    </div><!-- /.container-fluid -->
</section>

<section class="content">

    <div class="row">
        <div class="col-lg-5">
            <div class="card card-outline card-primary">
                <!-- form start -->
                <form class=" form-setting autoAjaxSubmit" autocomplete="off"
                      action="#if(type == "category") /admin/job/categoryDoSave #else if(type == "address") /admin/job/addressDoSave #end"

                data-ok-href="#if(type == "category") /admin/job/JobCategory #else if(type == "address") /admin/job/JobAddress #end"

                data-ok-message="保存成功"

                method="post">

                <div class="card-body ">
                    <input type="hidden" id="entryId" name="jobCategory.id" value="#(jobCategory.id ??)">

                    <div class="form-group row">
                        <label class="col-sm-2 col-form-label">名称</label>
                        <div class="col-sm-9">

                            <input type="input" name="jobCategory.title" class="form-control"
                                   value="#(jobCategory.title ??)"
                                   placeholder="请填写名称" required>
                        </div>
                    </div>

                    #if(type == "category")
                    <div class="form-group row">
                        <label class="col-sm-2 col-form-label">父分类</label>
                        <div class="col-sm-9">

                            <select class="form-control" name="jobCategory.pid">

                                <option value=0   #if(jobCategory && jobCategory.pid == 0) selected #end>顶级分类</option>

                                #for(item : categories)
                                <option value="#(item.id ??)" #if(item.id ??== jobCategory.pid ??) selected #else if(jobCategory && (item.id ?? == jobCategory.id ?? || item.parent.id ?? == jobCategory.id ?? )) disabled #end>
                                    #(item.layerString ??) #(item.title ??)
                                </option>
                                #end

                            </select>
                        </div>
                    </div>
                    #end

                    <div class="form-group row">
                        <label class="col-sm-2 col-form-label">摘要</label>
                        <div class="col-sm-9">

                            <textarea class="form-control" name="jobCategory.summary"
                                      rows="3">#(jobCategory.summary ??)</textarea>

                        </div>
                    </div>


                    <div class="form-group row">
                        <label class="col-sm-2 col-form-label">标识</label>
                        <div class="col-sm-9">

                            <input type="input" name="jobCategory.flag" class="form-control"
                                   value="#(jobCategory.flag ??)"
                                   placeholder="请填写标识">
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-sm-2 col-form-label">排序编码</label>
                        <div class="col-sm-9">

                            <input type="input" name="jobCategory.order_number" class="form-control"
                                   value="#(jobCategory.order_number ??)"
                                   placeholder="请填写排序编码">
                        </div>
                    </div>

                </div>
                <!-- /.card-body -->
                <div class="card-footer">
                    <div class="offset-sm-2 col-sm-10 submit-block">
                        <div class="card-submit">
                            <button type="submit" class="btn btn-primary">提交</button>
                        </div>
                    </div>
                </div>
                <!-- /.card-footer -->
                </form>
            </div>
        </div>
        <div class="col-lg-7">
            <div class="card card-outline card-primary">

                <div class="card-body p-0">

                    <table class="table table-striped table-action">
                        <thead>
                        <tr>
                            <th style="width: 100px">名称</th>

                            #if(type == "category")
                            <th style="width: 100px">父级</th>
                            #end

                            #if(type == "category")
                            <th style="width: 100px">该分类下的岗位数量</th>
                            #else if(type == "address")
                            <th style="width: 100px">摘要</th>
                            #end

                            <th style="width: 100px">标识</th>


                        </tr>
                        </thead>
                        <tbody>


                        #for(entry : categories ??)
                        <tr>
                            <td>
                                #(entry.layerString) #(entry.title)
                                <div class="jp-action-card">
                                    <div class="jp-action-body">
                                        <a href="#if(type == "category")/admin/job/JobCategory/#(entry.id) #else if(type == "address") /admin/job/JobAddress/#(entry.id) #end ">编辑</a> |
                                        <a href="javascript:;" class="red-action" onclick="doDel('#(entry.id)')">删除</a>
                                    </div>
                                </div>
                            </td>

                            #if(type == "category")
                            <td>
                                #if(entry.pid ?? == 0) 顶级 #else #(entry.parent.title ??) #end
                            </td>
                            #end

                            #if(type == "category")
                            <td>#(entry.count)</td>
                            #else if(type == "address")
                            <td>#maxLength(entry.summary ??,10)</td>
                            #end

                            <td>#(entry.flag ??)</td>

                        </tr>
                        #end

                        </tbody>
                    </table>

                </div>

                <div class="card-footer">
                    <div class="row">
                        <div class="col-sm-12">
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.card -->
        </div>
    </div>
</section>

#end
